package com.cloud.adrian.novel.user.feign;

import com.cloud.adrian.novel.common.constant.ApiRouterConstants;
import com.cloud.adrian.novel.common.resp.RestResp;
import com.cloud.adrian.novel.user.dto.resp.UserInfoRespDto;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PostMapping;

import java.util.ArrayList;
import java.util.List;

/**
 * 用户微服务调用客户端
 * @Author: xiangguiliang
 * @version: 1.0
 * @since: 2024/05/23
 */
@Component
@FeignClient(name = "novel-user-service", fallback = UserFeign.UserFeignFallback.class)
public interface UserFeign {

    /**
     * 根据用户id列表查询用户信息
     * @param userIds 用户id列表
     * @return 用户信息列表
     */
    @PostMapping(ApiRouterConstants.API_INNER_USER_URL_PREFIX + "/listUserInfoByIds")
    RestResp<List<UserInfoRespDto>> listUserInfoByIds(List<Long> userIds);

    @Component
    class UserFeignFallback implements UserFeign{
        @Override
        public RestResp<List<UserInfoRespDto>> listUserInfoByIds(List<Long> userIds) {
            return RestResp.ok(new ArrayList<>(0));
        }
    }
}